﻿using IntelliLock.Licensing;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Yb;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;

namespace YbPrintPlug
{
    public partial class AboutWindow : Form
    {
        public AboutWindow()
        {
            InitializeComponent();
            switch (EvaluationMonitor.CurrentLicense.LicenseStatus)
            {
                case LicenseStatus.Licensed:
                    label1.Hide();
                    textBox1.Hide();
                    button1.Hide();
                    break;
                case LicenseStatus.EvaluationExpired:

                case LicenseStatus.HardwareNotMatched:
                case LicenseStatus.LicenseFileNotFound:
                case LicenseStatus.EvaluationMode:
                case LicenseStatus.ServerValidationFailed:
                case LicenseStatus.InvalidSignature:
                case LicenseStatus.NotChecked:
                case LicenseStatus.Reactivated:
                case LicenseStatus.Deactivated:
                default:
                    string code= HardwareID.GetHardwareID(true, false, false, true, true, false);
                    textBox1.Text = code;
                    textBox1.ReadOnly = true;
                    label2.Hide();
                    break;
            }
        }

        private void closewindow_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel; // 或 DialogResult.OK 等
            this.Close();
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                string url = "http://www.ybxxjs.com"; // 替换为你想打开的链接

                // 标记链接为已访问（可选）
                linkLabel1.LinkVisited = true;

                // 跨平台安全打开 URL
                System.Diagnostics.Process.Start(url);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"无法打开链接：{ex.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(textBox1.Text))
            {
                Clipboard.SetText(textBox1.Text);
                MessageBox.Show("已复制到剪贴板！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
    }
}
